VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Detect \ in directory

by Eric LeBourgeois (3 Submissions)
Category: Coding Standards
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (9 Votes)

Suppose You try to get the app.path when the app is in the C Drive. the result is "C:\". if the app is in another directory the result may be "C:\Directory". notice there is no backslash. most people skip this because they don't think it is a problem, but it is. when you put in a program, app.path & "\filename.file", when it is in the C Drive or if you put app.path & "filename.file" in a named directory, the computer will either return "C:\\filename.file" or "C:\Directoryfilename.file". this code will show you how to detect the backslash and deal with it.

Rate Detect \ in directory

'this code will give you a valid filename, whether the app.path return has a backslash or not, and displays a message box.
'Please Vote for me at Planet Source Code
if right(app.path,1) = "\" then 'sees if the directory has a backslash at the end of it
msgbox app.path & "filename.file"
goto ResumeMe
end if
msgbox app.path & "\filename.file"
ResumeMe:

Download this snippet    Add to My Saved Code

Detect \ in directory Comments

No comments have been posted about Detect \ in directory. Why not be the first to post a comment about Detect \ in directory.

Post your comment

Subject:
Message:
0/1000 characters